// 输入框组件实例

import { assignInWith } from 'lodash'
import type { dateRangeConfigType, inputConfigType } from '../../../../../types/index'
import BaseEntity from '../../BaseEntity'
import { uid } from 'uid'
import type { configType, slotFormConfigType } from '../../BaseEntity'
import { entityType } from '../..'
export default class DateRangeEntity extends BaseEntity {
    

    constructor(config: configType, slotFormConfig: slotFormConfigType) {
        let baseConfig: configType = {
            class: ['draggable-form-hover'],
            style: { width: '100%' },
            field: 'Date_Range_' + uid(4),
            label: '日期范围选择',
            required: false,
            hideLabel: false
        }
        let baseSlotFormConfig = {
            modelValue: [],
            valueFormat: 'YYYY-MM-DD',
            format:'YYYY-MM-DD',
       
        }
        let componentConfig: dateRangeConfigType = {
     
            valueFormat: {
                type: 'select',
                formItemConfig: {
                    label: '日期值格式'
                },
                formItemElement: {
                    modelValue: "YYYY-MM-DD",
                    options: [
                        { label: '年-月-日', value: 'YYYY-MM-DD' },
                        { label: '年-月-日 时:分:秒', value: 'YYYY-MM-DD HH:mm:ss' },
                        { label: '月-日-年 时:分:秒', value: 'MM-DD-YYYY HH:mm:ss' },
                        { label: '月-日-年', value: 'MM-DD-YYYY' },
                    ],
                    placeholder: '请选择日期选择时获取得值格式'
                }
            },
            format: {
              type: 'select',
              formItemConfig: {
                  label: '展示日期格式'
              },
              formItemElement: {
                  modelValue: "YYYY-MM-DD",
                  options: [
                      { label: '年-月-日', value: 'YYYY-MM-DD' },
                      { label: '年-月-日 时:分:秒', value: 'YYYY-MM-DD HH:mm:ss' },
                      { label: '月-日-年 时:分:秒', value: 'MM-DD-YYYY HH:mm:ss' },
                      { label: '月-日-年', value: 'MM-DD-YYYY' },
                  ],
                  placeholder: '请选择所需要展示的日期格式'
              }
          }
        }

        super(
          entityType.dateRange,
            assignInWith(baseConfig, config),
            assignInWith(baseSlotFormConfig, slotFormConfig),
            componentConfig
        )
        this.initSlotFormConfig()
    }
    initSlotFormConfig(){
      //初始化表单组件可配置项 因为表单组件可配置项是根据表单组件所拥有得属性来定义的 配置项得值需要对应初始化实例得对应属性得值

      this.componentConfig.valueFormat.formItemElement.modelValue= this.slotFormConfig["valueFormat"]
      this.componentConfig.format.formItemElement.modelValue= this.slotFormConfig["format"]
    }
}
